package roborally.program.commands;

import roborally.model.Robot;

/**
 * A class for dealing with basic commands.
 * 	This are commands which respond directly to an action.     
 * 
 * @version	1.0
 * @author  Pieter Robberechts	(1e Bach Informatica)
 * @author	Jeroen Sanders		(1e Bach Informatica)
 *
 */
public abstract class BasicCommand extends Command {
	
	/**
	 * Initialize this new basic command with a line number.
	 * 
	 */
	public BasicCommand(int lineNb) {
		super(lineNb);
	}

	/**
	 * Execute this basic command on the given robot.
	 * 
	 * @param 	robot
	 * 			The robot on which the command should be executed.
	 * @throws 	IllegalArgumentException
	 * 			The given robot should be effective.
	 * 			| robot == null
	 * @throws	IllegalArgumentException
	 * 			The robot should be located on a board.
	 * 			| robot.getBoard() == null
	 */
	public void execute(Robot robot) throws IllegalArgumentException {
		if(robot == null)
			throw new IllegalArgumentException("The given robot should be effective!");
		if(robot.getBoard() == null)
			throw new IllegalArgumentException("The robot should be located on a board!");
	}

	/**
	 * Return this basic command if its line number is larger than the given 
	 * line number, else return null.
	 * 
	 * @return	Return 'this' if the line number of this basic command
	 * 			is larger than the given line number; else return null.
	 * 			| if(getLineNb() > lineNb)
	 *			|	then result == this
	 *			| else if(getLineNb() <= lineNb)
	 *			|	then result == null
	 */
	@Override
	public BasicCommand getNextBasicCommand(int lineNb, Robot robot) {
		if(getLineNb() > lineNb)
			return this;
		return null;
	}

}
